<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Certification extends WdController {

	/**
	 * 查看钓场认证资料
	 */
	public function state(){

		$apiid = isset($_GET["apiid"]) ? intval($_GET["apiid"]) : 0;

		$api = \libraries\waydiao\Wdata::getApi($apiid);

		$data = [
			'hosts' => $this->config->item('api_host_yuxun'),
			'api' => $api,
		];

		$this->load->view('certification/state', $data);

	}

	public function asyncState(){

		$api_id = isset($_POST["api_id"]) ? intval($_POST["api_id"]) : 0;
		$api_host = isset($_POST["api_host"]) ? addslashes($_POST["api_host"]) : "";
		$Authorization = $this->access_token;

		$fid = isset($_POST["fid"]) ? addslashes($_POST["fid"]) : "";

		echo $api_id."<br>";

		$api = \libraries\waydiao\Wdata::getApi($api_id);

		$request_url = $api_host.$api["url"];
		echo $request_url."<br>";

		$data = [
			'fid' => $fid,
		];

		pre($data);

		$header = ["Authorization:Bearer ".$Authorization];

		$r = curl_post_header($request_url, json_encode($data), $header);

		var_dump($r);

		$r2 = json_decode($r);
		pre($r2);

	}
}
